home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1996 April: Mac OS SDK / Dev.CD Apr 96 SDK / Dev.CD Apr 96 SDK1.toast / Development Kits (Disc 1) / OpenDoc / Sample Code / Sample Editors⁄Viewers / Script Runner / ScriptRunner Read Me < prev    next >
Encoding:
Text File  |  1995-12-15  |  4.6 KB  |  66 lines  |  [TEXT/ttxt]

  1. ScriptRunner Read Me
  2. By The OpenDoc™ Sample Code Team
  3. December 15, 1995
  4.  
  5.  
  6. © 1993-1995  Apple Computer, Inc. All Rights Reserved.
  7. Apple, the Apple logo, and Macintosh are registered trademarks of Apple Computer, Inc.
  8. Mac and OpenDoc are trademarks of Apple Computer, Inc.
  9. ----------------------------------------------------------------------------------------------------------------------------
  10.  
  11. Installation
  12.  
  13. Currently, the ScriptRunner part only works in conjunction with the TextEditor part, and is not intended to run independently.  (Remember that TextEditor only runs on Power PC!)  In order to run ScriptRunner, be sure to place the OSA PlugIn shared library in the "OpenDoc Shell Plug-Ins" folder within the Editors folder, and place the ScriptRunner shared library in the Editors folder.  
  14.  
  15. Functionality
  16.  
  17. The TextEditor part needs to be active, either as a root document or embedded.  To activate ScriptRunner, select the "Show ScriptRunner" item in the Tools menu of the TextEditor part.  (Note: if this menu item is greyed out, close the document, delete the Text Editor Preferences file from the Preferences folder in the System folder, and reopen the document).  A floating palette will appear containing the control buttons to compile and run scripts.  When selecting one of these actions, the ScriptRunner retrieves the selected text from TextEditor and uses that as the script data.  If no text is selected at this time, the TextEditor part returns its entire contents.  After a script is executed, a floating result window will appear containing the result (or "< no result >").  The result value can be dragged to another part or to the desktop, as plain text data.
  18.  
  19. Project
  20.  
  21. The ScriptRunner project consists of several pieces:  a data transfer extension, OSA plug-in, scripting palette extension, and the ScriptRunner part.  The "ScriptRunner Mechanics" document provides an overview diagram of these components.  The following describes each piece in more detail.
  22.  
  23. OSA Plug-In
  24.  
  25. The purpose of this OpenDoc plug-in is to create a name space and register the ScriptRunner agent object into it.  This allows a client to retrieve the agent object from the name space and then acquire the scripting palette extension via the agent.
  26.  
  27. Scripting Palette Extension
  28.  
  29. This extension belongs to the ScriptRunner part, and allows clients to manipulate the scripting palette (eg. Hide, Show, Move).  The palette extension provides an API for client parts, and passes all requests onto the ScriptRunner part.
  30.  
  31. ScriptRunner part
  32.  
  33. The ScriptRunner part provides the implementation for the floating palette window and result window.  ScriptRunner is responsible for fulfilling the requests from the palette extension.  An OSA helper object is utilized to invoke the OSA scripting capabilities.  The palette is global, meaning that the same palette is used by all clients within one process.
  34.  
  35. Data/Text Transfer Extension
  36.  
  37. This extension provides data interchange capabilities between parts.  The Text Transfer extension is a subclass of the Data Transfer Extension class and adds support for text-specific data.  When a client registers itself as the current client through the palette extension, the ScriptRunner part retrieves the Text Transfer extension from the client to allow data interchange.  
  38.  
  39.  
  40. How To Build 
  41.  
  42. ScriptRunner consists of two projects:  OSAPlugIn and ScriptRunner.  Note that the ScriptRunner part is "weak" linked against the AppleScriptLib.  The client part should also "weak" link against the "ScriptRunner Agent.stub" and "ScriptRunner.stub" libraries in the event that they are not installed.
  43.  
  44. ScriptRunner Agent.stub
  45.  
  46. To create the stub library for the client part to link against, follow these steps:
  47.  
  48. 1)  Make a copy of the OSA PlugIn shared library
  49. 2)  Rename the copy to "ScriptRunner Agent.stub"
  50. 3)  Open the stub library in ResEdit
  51. 4)  Open the 'cfrg' resource, change the Member Count to 1, and delete the second member.  
  52.      Only the class name is needed to link against, otherwise duplicate errors will occur.
  53. 5)  Save the resource.
  54.  
  55. ScriptRunner.stub
  56.  
  57. Follow the steps outlined above, using a copy of the ScriptRunner library which is renamed to "ScriptRunner.stub".
  58.  
  59.  
  60. The Next Steps
  61.  
  62. 1)  Recording is not available in the 1.0 version of ScriptRunner.  In order to capture the events within OpenDoc,, a part would need to either install a handler or install a dispatch module specifying that it wants to intercept high-level events, and then call the OSAStartRecording routine.  Installing a handler into the part is recommended for performance reasons.
  63.  
  64. 2)  Ideally, it would be nice to handle errors by having the client highlight the range of text where the scripting error occurred.
  65.  
  66.